package com.cloud.salon.client.authority.repository;

import com.cloud.salon.common.base.entity.authority.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Description 用户仓库接口
 * @Author wolf--LZH
 * @CreateDate 2019/4/10 0010 下午 1:30
 */
public interface UserRepository extends JpaRepository<User, Integer> {

    User findByUsername(String username);

    @Query(value = "SELECT u.* FROM user_role ur "
            + "JOIN `user` u ON u.id = ur.user_id "
            + "WHERE ur.role_id = ?1", nativeQuery = true)
    List<User> findByRole(Integer roleId);
}